#include "compile_run.hpp"
#include "../comm/httplib.h"

using namespace ns_compile_run;
using namespace httplib;

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "./a.out port" << std::endl;
        return 0;
    }
    Server svr;
    svr.Post("/compile_run", [](const Request &req, Response &resp)
             {
        std::string in_json=req.body;
        std::string out_json;
        if(!in_json.empty())
        {
            compile_run::Start(in_json,&out_json);
            // std::cout<<out_json<<std::endl;
            resp.set_content(out_json,"application/json;charset=utf-8");
        } });
    svr.listen("0.0.0.0", atoi(argv[1]));

    return 0;
}
